
<?php
//模块插件类
//对外接口函数类，其他插件可通过“$this->plugin('模块名称')->方法名” 来调用本类的方法
defined('BY_JYA') or exit('error');

//use Aliyun\DySDKLite\Vms\Demo;
class func_jy_wxsemantic extends plugin{
	
	//$mobile为目标号码 $content为模板变量数组 $mid为模板id
	public function post($setting,$query,$openid){
		$setting=$this->plugin_setting('setting');
		$appid=pdo_getcolumn('core_account_wechat',array('uniacid'=>$_SESSION['uniacid'],'isdefault'=>1),'appid');
		$token = cfc('account')->getAccessToken();
		$url='https://api.weixin.qq.com/semantic/semproxy/search?access_token='.$token;
		$type1=array('1'=>'datetime','2'=>'location','3'=>'number');
		$sevices1=array('1'=>'restaurant','2'=>'map','3'=>'nearby','4'=>'coupon');
		$sevices2=array('1'=>'hotel','2'=>'travel','3'=>'fliht','4'=>'train');
		$sevices3=array('1'=>'movie','2'=>'music','3'=>'video','4'=>'novel');
		$sevices4=array('1'=>'weather','2'=>'stock','3'=>'remind','4'=>'telephone');
		$sevices5=array('1'=>'cookbook','2'=>'baike','3'=>'news');
		$sevices6=array('1'=>'tv','2'=>'instruction','3'=>'tv_instruction','4'=>'car_instruction','5'=>'app','6'=>'website','7'=>'search');
		if($setting['xieyi']==1){
			$category=$type1[$setting['type1']];
		}elseif($setting['xieyi']==2){
			$num='sevices'.$setting['type2'];
			$category=$setting[$num];//sevices的值
			$v=explode(';',$category);
			$category='';
			foreach($v as $k){
			$sevices=$$num;
			$category .= ','.$sevices[$k];
			}
			$category=substr($category,2,-1);
		}
		$post=array(
		'query'=>$query,
		'city'=>$setting['city']['city'],
		'category'=>$category,
		'appid'=>$appid,
		'uid'=>$openid
		);
		$result=cfc('http')->ihttp_request($url,json_encode($post));
		
		return $result['content'];
	}
	
}
?>
